//
//  ViewController.swift
//  FromWatchToCircle
//
//  Created by 张海峰 on 2018/5/31.
//  Copyright © 2018年 张海峰. All rights reserved.
//
/*写该demo的目的：主要是想从时钟开始，一步步窥见项目中和圆有关的东西，从而学习巩固，加深理解。
 (项目不定时更新，所以最好从下面地址获取最新demo),感觉我这个demo对你有启发或者帮助，欢迎fork 感谢star
 https://github.com/FighterLightning/FromWatchToCircle.git
 */
import UIKit
//设备物理尺寸
let ScreenHeight = UIScreen.main.bounds.size.height
let ScreenWidth = UIScreen.main.bounds.size.width
class ViewController: UIViewController {
    var tableView:UITableView!
    lazy var dataMarr:NSMutableArray = NSMutableArray()
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "从时钟到圆"
        self.addTableView()
        self.dataMarr = ["时钟","多种圆形进度条","转盘"]
    }
    func addTableView(){
        tableView = UITableView.init(frame: CGRect.init(x: 0, y: 44, width: ScreenWidth, height: ScreenHeight - 44), style: UITableViewStyle.plain)
        self.view.addSubview(tableView)
        tableView.backgroundColor = ZHFColor.zhff9_backGroundColor
        tableView.separatorColor = ZHFColor.zhf_strColor(hex: "cccccc")
        tableView.separatorInset = UIEdgeInsets.init(top: 0, left: 25, bottom: 0, right: 0)
        tableView.delegate = self
        tableView.dataSource = self
    }
}
extension ViewController :UITableViewDataSource,UITableViewDelegate
{
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.dataMarr.count
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let alertCellIdentifier  = "alertCellIdentifier"
        var cell = tableView.dequeueReusableCell(withIdentifier: alertCellIdentifier)
        if cell == nil {
            cell = UITableViewCell(style:.default, reuseIdentifier: alertCellIdentifier)
        }
        cell?.textLabel?.text = self.dataMarr[indexPath.row] as? String
        cell?.textLabel?.font = UIFont.systemFont(ofSize: 13)
        cell?.textLabel?.textColor = ZHFColor.zhf66_contentTextColor
        cell?.selectionStyle = UITableViewCellSelectionStyle.none
        return cell!
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if indexPath.row == 0 {
            let clockView: ClockView = ClockView()
            UIApplication.shared.keyWindow?.addSubview(clockView.initClockView())
        }
        else if indexPath.row == 1 {
            let progressVC:ProgressVC = ProgressVC()
            self.navigationController?.pushViewController(progressVC, animated: true)
            
        }
        else if indexPath.row == 2 {
            let luckyWheelView: LuckyWheelView = LuckyWheelView()
            UIApplication.shared.keyWindow?.addSubview(luckyWheelView.initLuckyWheelView())
        }
        else if indexPath.row == 3 {
          
        }
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 40
    }
}

